package com.giaothong.model;

import java.util.ArrayList;

import org.json.JSONObject;

import com.giaothong.model.entity.LocationSearchEntity;
import com.giaothong.utils.JSONUtil;

public class ModelGetLocationInfoGoogleApiRequest {
	private String status = "";
	private ArrayList<LocationSearchEntity> locationStatus;

	/**
	 * setter& getter
	 */
	public void setLocationStatus(ArrayList<LocationSearchEntity> locationStatus) {
		this.locationStatus = locationStatus;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public ArrayList<LocationSearchEntity> getLocationStatus() {
		return locationStatus;
	}

	public String getStatus() {
		return status;
	}

	/**
	 * contructor
	 */
	public ModelGetLocationInfoGoogleApiRequest() {
		setDefautValue();
	}

	public ModelGetLocationInfoGoogleApiRequest(JSONObject jsonObject) {
		setDefautValue();
		if (jsonObject == null)
			return;
		this.status = JSONUtil.stringTryGetValue(jsonObject, "status");
		if (!this.status.equals("OK"))
			return;
		ArrayList<JSONObject> list = JSONUtil.jsonArrayTryGetValue(jsonObject, "results");
		for (int i = 0; i < list.size(); i++) {
			this.locationStatus.add(new LocationSearchEntity(list.get(i)));
		}
	}

	private void setDefautValue() {
		this.status = "";
		this.locationStatus = new ArrayList<LocationSearchEntity>();
	}
}
